package com.heaven.service;

import com.heaven.mapper.IntroMapper;
import com.heaven.pojo.Intro;
import com.heaven.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class IntroServiceImpl implements IntroService{
    @Autowired
    private IntroMapper introMapper;
    @Override
    public PageResult findIntro(PageResult pageResult) {
        int size=pageResult.getPageSize();
        int startNum=(pageResult.getPageNum()-1)*size;
        String query=pageResult.getQuery();

        List<Intro> row=introMapper.findIntro(size,startNum,query);
        long total=introMapper.findCount(query);
        pageResult.setTotal(total).setRows(row);
        return pageResult;
    }

    @Override
    @Transactional
    public void deleteIntroById(Integer id) {
        introMapper.deleteIntroById(id);
    }
}
